package com.hc;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.io.IOException;
import java.lang.reflect.Type;

//fastjson自定义序列号
public class DoubleSerialize2 implements ObjectSerializer {
    /**
     *
     * @param jsonSerializer
     * @param o 原属性值
     * @param o1 属性名
     * @param type 属性类型
     * @param i
     * @throws IOException
     */
    @Override
    public void write(JSONSerializer jsonSerializer, Object o, Object o1, Type type, int i) throws IOException {
        Double value = (Double) o; //以Double为例
        String string = value + "元";
        jsonSerializer.write(string);
    }
}
